package com.leyou.item.client;

import com.leyou.common.vo.PageResult;
import com.leyou.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {

    @GetMapping("/spu/page")
    public PageResult<SpuDTO> querySpuByPage(
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "rows",defaultValue = "5")Integer rows,
            @RequestParam(value = "key",required = false)String key,
            @RequestParam(value = "saleable",required = false)Boolean saleable
    );

    @GetMapping("/sku/of/spu")
    public List<SkuDTO> findSkuById(@RequestParam(value = "id")Long id);


    @GetMapping("/spec/params")
    public List<SpecParamDTO> querySpecParams(
            //可能根据 gid 查询 商品的具体规格
            //也可能根据 cid 查询 搜索页面的用户需要查询的 规格
            @RequestParam(value = "gid",required = false)Long gid,
            @RequestParam(value = "cid",required = false)Long cid,
            @RequestParam(value = "searching",required = false)Boolean searching
    );

    @GetMapping("/spu/detail")
    public SpuDetailDTO findSpuDetailById(@RequestParam(value = "id")Long id);

    @GetMapping("/category/list")
    public List<CategoryDTO> findByCategorysByIds(@RequestParam(value = "ids")List<Long> ids);


    @GetMapping("/brand/{id}")
    public BrandDTO queryBrandById(@PathVariable(value = "id")Long id);

    @GetMapping("/spu/{id}")
    public SpuDTO findSpuBySpuId(@PathVariable("id") Long id);

    @GetMapping("/spec/groups/of/category/params")
    public List<SpecGroupDTO> findSpecGroupWithParamsBuCid(@RequestParam("id") Long id );

    @GetMapping("/sku/list")
    public List<SkuDTO> findSkusBySkuIds(@RequestParam(value = "ids") List<Long> ids );

    @PutMapping("/stock/minus")
    public Void minusStock(@RequestBody Map<Long,Integer> map);
}
